package com.mayblackcat.dy.dao;

import com.mayblackcat.dy.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

@Repository
public interface LoginDao {
    @Select("select * from t_user where userName=#{userName} and password=#{password}")
    public User findByUser(String userName, String password);


    //注册
    @Insert("insert into t_user(userName,password,email,sex,avatar,createTime,status) values(#{userName},#{password},#{email},#{sex},#{avatar},#{createTime},#{status})")
    public void  registerUser(String userName, String password,String email,String sex,String avatar, Date createTime,int status);

    //用户名查询
    @Select("select * from t_user where userName=#{userName}")
    public User findByName(String userName);

    @Select("select * from t_user")
    public List<User> findByAll();

    @Update("update t_user set status=#{status} where id=#{id}")
    public boolean updateStatus(User user);

    @Select("select * from t_user where id=#{id}")
    public User getAvatarById(Long id);

    @Select("select status from t_user where id=#{id}")
    public int getStatusById(Long id);
}
